package request

import (
	model2 "mallgo/internal/common/model"
	"mallgo/internal/resources/product/model"
	"time"
)

type ProductCatalogRequest struct {
	ID       int64   `json:"id"`
	Name     *string `json:"name"`
	Status   int64   `json:"status"`
	ParentID *int64  `json:"parent_id"`
	SortNum  *int64  `json:"sort_num"`
}

func ConvertProductCatalogModel(request *ProductCatalogRequest) *model.ProductCatalog {
	addDate := time.Now()
	date1 := &addDate
	lastDate := time.Now()
	date2 := &lastDate
	return &model.ProductCatalog{
		CatalogModel: model2.CatalogModel{
			BaseModel: model2.BaseModel{
				AddDate:  date1,
				LastDate: date2,
			},
			Name:     request.Name,
			ParentID: request.ParentID,
			SortNum:  request.SortNum,
		},
		Status: request.Status,
	}
}
